<?php

class Webkul_Marketplacepartner_Block_Feedbackadmin_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct(){
        parent::__construct();
        $this->setId('feedbackGrid');
        $this->setUseAjax(true);
        $this->setDefaultSort('feedid');
        $this->setSaveParametersInSession(true);
    }

    protected function _prepareCollection(){
		 $collection=Mage::getModel('marketplacepartner/feedback')->getCollection()->setOrder('feedid','des');
		 foreach($collection as $item){
			$item->name=Mage::getModel('customer/customer')->load($item->getUserid())->getName();
			$item->partner_name=Mage::getModel('customer/customer')->load($item->getProownerid())->getName();
			$item->status=$item->getStatus()==0? "Unapproved":"Approved";
		 }
		 $this->setCollection($collection);
		 
		 return parent::_prepareCollection();
    }

    protected function _prepareColumns(){
        $this->addColumn('feedid', array(
            'header'    => Mage::helper('customer')->__('ID'),
            'width'     => '50px',
            'index'     => 'feedid',
            'type'  => 'number',
			'filter'    => false,
            'sortable'  => false
        ));
        $this->addColumn('name', array(
            'header'    => Mage::helper('customer')->__('Name'),
            'index'     => 'name',
			'filter'    => false,
            'sortable'  => false
        ));
        $this->addColumn('partner_name', array(
            'header'    => Mage::helper('customer')->__('Partner Name'),
            'width'     => '150',
            'index'     => 'partner_name',
			'filter'    => false,
            'sortable'  => false
        ));
		// for partner status
		$this->addColumn('feedprice', array(
            'header'    => Mage::helper('customer')->__('Feed Price'),
            'index'     => 'feedprice',
			'filter'    => false,
            'sortable'  => false
        ));
		$this->addColumn('feedvalue', array(
            'header'    => Mage::helper('customer')->__('Feed Value'),
            'index'     => 'feedvalue',
			'filter'    => false,
            'sortable'  => false
        ));
		$this->addColumn('feedquality', array(
            'header'    => Mage::helper('customer')->__('Feed Quality'),
            'index'     => 'feedquality',
			'filter'    => false,
            'sortable'  => false
        ));
		$this->addColumn('feedsummary', array(
            'header'    => Mage::helper('customer')->__('Feed Summary'),
            'index'     => 'feedsummary',
			'filter'    => false,
            'sortable'  => false
        ));
		$this->addColumn('feedreview', array(
            'header'    => Mage::helper('customer')->__('Feed Review'),
            'index'     => 'feedreview',
			'filter'    => false,
            'sortable'  => false
        ));
		$this->addColumn('createdat', array(
            'header'    => Mage::helper('customer')->__('Created At'),
            'index'     => 'createdat',
			'filter'    => false,
            'sortable'  => false
        ));
		$this->addColumn('status', array(
            'header'    => Mage::helper('customer')->__('Status'),
            'index'     => 'status',
			'filter'    => false,
            'sortable'  => false
        ));
		
        return parent::_prepareColumns();
    }

    protected function _prepareMassaction(){
        $this->setMassactionIdField('entity_id');
        $this->getMassactionBlock()->setFormFieldName('feedid');
		$this->getMassactionBlock()->addItem('approve', array(
             'label'    => Mage::helper('customer')->__('Approve'),
             'url'      => $this->getUrl('*/*/approve')
        ));
		$this->getMassactionBlock()->addItem('unapprove', array(
             'label'    => Mage::helper('customer')->__('Unapprove'),
             'url'      => $this->getUrl('*/*/unapprove')
        ));
		$this->getMassactionBlock()->addItem('massdelete', array(
             'label'    => Mage::helper('customer')->__('Delete'),
             'url'      => $this->getUrl('*/*/massdelete')
        ));
        return $this;
    }
}
